<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
	<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>序列编码管理</title>
<style type="text/css">
	@import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
	@import "../dojo-release-1.5.0/dojo/resources/dojo.css";
	@import "../dojo-release-1.5.0/dojox/grid/resources/tundraGrid.css";
</style>
<script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="../framework/uiutil.js"></script>
<script type="text/javascript" src="../framework/simpleCRUDUtil.js"></script>

<script type="text/javascript">
var SCU = new SimpleCrudUtil({
	c:"../bkgrd/saveOrUpdateSerialCode.do",
	u:"../bkgrd/saveOrUpdateSerialCode.do",
	r:"../bkgrd/getAllSerialCode.do",
	d:"../bkgrd/deleteSerialCode.do",
	grid:"grid",
	idName:"codeName",
	translateFun:function(item){
		item["isCycleStr"] = item["isCycle"]?"是":"否";
		item["isAvailableStr"] = item["isAvailable"]?"启用":"停用";
		var toUsedRetrievedCodeStr = ""
		for(var i in item["retrievedCodeList"]){
			toUsedRetrievedCodeStr += (item["retrievedCodeList"][i]+"\r\n");
		}
		item["toUsedRetrievedCode"] = toUsedRetrievedCodeStr;
	}
});

dojo.addOnLoad(function(){
	SCU.R();
});

function refreshList(){
	SCU.R();
}

function saveOrUpdateSerialCode(){
	var codeName = dojo.byId("codeName").value;
	var description = dojo.byId("description").value;
	var scheme = dojo.byId("scheme").value;
	var nowCode = dojo.byId("nowCode").value;
	var isCycle = D.getSingleCheckBoxCheckedInt("isCycle");
	var isAvailable = D.getSingleCheckBoxCheckedInt("isAvailable");
	
	if(codeName == '' || scheme == ''){
		alert("请至少输入序列名称和模式");
		return;
	}

	var model = {codeName:codeName,description:description,scheme:scheme,nowCode:nowCode,
			isCycle:isCycle,isAvailable:isAvailable};
	if(SCU.dupl(codeName)){
		if(!confirm("参数已存在，是否确认更新？"))return;
		SCU.U(model);
	}else{
		SCU.C(model);
	}
}

//删除参数
function deleteSerialCode(){
	SCU.D();
}

//开始修改
function startModifySerialCode(){
	var item = SCU.getSelectedItem();
	if(item == null)return;
	
	dojo.byId("codeName").value = item["codeName"];
	dojo.byId("description").value = item["description"];
	dojo.byId("scheme").value = item["scheme"];
	dojo.byId("nowCode").value = item["nowCode"];
	dijit.byId("isCycle").setChecked(item["isCycle"]!=0);
	dijit.byId("isAvailable").setChecked(item["isAvailable"]!=0);
}


</script>

<style type="text/css">
#grid{
	border:1px solid #333;
	width:80%;
	margin:10px;
	height:200px;
	font-size:0.9em;
}
</style>
</head>
<body class="tundra">


新增序列编码
<table width="100%">
<tr><td>编码名称</td><td><input type="text" dojoType="dijit.form.TextBox" id="codeName" size="100" trim="true" value=""/></td></tr>
<tr><td>描述</td><td><input type="text" dojoType="dijit.form.TextBox" id="description" size="100" trim="true" value=""/></td></tr>
<tr><td>模式</td><td><input type="text" dojoType="dijit.form.TextBox" id="scheme" size="100" trim="true" value="" style="width: 400px"/></td></tr>
<tr><td>是否启用</td><td><input dojoType="dijit.form.CheckBox" checked = "true" id="isAvailable"/>同名编码规则只能启用1个
</td></tr>
<tr><td colspan="2">
<p>
序列模式规则如下：<br/>
1、静态符号直接写；<br/>
2、范围符号格式$类型[起-值]，类型包括：16进制(H)，10进制(D)，小写字母(c)，大写字母(C)<br/>
3、例如：$H[x-y]16进制符号，1-9-A-F；$D[0-9]10进制符号；$c[a-z]小写字母；$C[A-Z]大写字母<br/>
4、例如ABC$H[0-F]$H[0-A]$H[0-F]12，可匹配ABCDA0123、ABCDA1123、ABCDA2123、ABCE00123等<br/>
</p>

</td></tr>

<tr><td>起始编码</td><td><input type="text" dojoType="dijit.form.TextBox" id="nowCode" size="30" trim="true" value=""/></td></tr>
<tr><td>循环使用</td><td><input dojoType="dijit.form.CheckBox" id="isCycle"/>循环使用</td></tr>

<tr><td colspan="2">
<button dojoType="dijit.form.Button" id="query" onclick="saveOrUpdateSerialCode()">保存参数</button>
<button dojoType="dijit.form.Button" id="delete" onclick="deleteSerialCode()">删除参数</button>
<button dojoType="dijit.form.Button" id="modify" onclick="startModifySerialCode()">修改参数</button>
<button dojoType="dijit.form.Button" id="refreshList" onclick="refreshList()">刷新</button>
</td></tr>
</table>

<table dojoType="dojox.grid.DataGrid" id="grid"  autoWidth="true">
 <thead>
	<tr>
	     <th field="codeName" width="100px">编码名</th>
	     <th field="description" width="200px">编码描述</th>
	     <th field="scheme" width="300px">模式</th>
	     <th field="nowCode" width="100px">当前编码值</th>
	     <th field="toUsedRetrievedCode" width="100px">回收待用值</th>
	     <th field="isCycleStr" width="100px">循环使用</th>
	     <th field="isAvailableStr" width="100px">启用状态</th>
	</tr>
</thead>
</table>

</body>
</html>